package com.neu.service;

import com.neu.dao.RoomDao;
import com.neu.pojo.Room;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RoomServiceImpl implements RoomService{
    @Autowired
    private RoomDao roomDao;

    /**
     * 获取全部房间信息
     * @return
     */
    @Override
    public List<Room> getRoomList() {
        return roomDao.getRoomList();
    }

    /**
     * 根据房间号删除房间
     * @param roomNum
     * @return
     */
    @Override
    public int delRoom(int roomNum) {
        int res=roomDao.delRoom(roomNum);
        return res;
    }

    /**
     * 根据房间号更新房间
     * @param room
     * @return
     */
    @Override
    public int updateRoom(Room room) {
        int res=roomDao.updateRoom(room);
        return res;
    }

    /**
     * 新增房间
     * @param room
     * @return
     */
    @Override
    public int addRoom(Room room) {
        int res=roomDao.addRoom(room);
        return res;
    }

    /**
     * 获取房间总数
     * @return
     */
    @Override
    public int getRoomCount() {
        int res=roomDao.getRoomCount();
        return res;
    }

    /**
     * 按页获取房间
     * @return
     */
    @Override
    public List<Room> getRoomByPage(int page,int limit) {
        return roomDao.getRoomByPage((page-1)*limit,limit);
    }

    /**
     * 跟据房间号获取房间信息
     * @param roomNum
     * @return
     */
    @Override
    public Room getRoomByRoomNum(int roomNum) {
        return roomDao.getRoomByRoomNum(roomNum);
    }


}

